
<div class="ui-portlet-header">
			      <span class="title">发票信息</span>            
</div>    
<style>
form{border: 1px solid #ccc;padding: 5px;}
.form-horizontal .form-group{margin:0;}
</style>
<script>
{{if $datainfo['OrderInvoice']['status'] == 0}}
 //ajaxAction('/admin/order_invoices/edit/{{$datainfo['OrderInvoice']['id']}}',{'data[OrderInvoice][status]':1},null,function(){showSuccessMessage('发票已受理，锁定用户不可更改');});
{{/if}}

$(function(){
	$('#OrderInvoiceInvoiceNumber1').on('keyup blur',function(){
		$('#OrderInvoiceInvoiceNumber2').val($('#OrderInvoiceInvoiceNumber1').val());
	});
	
});
</script>

{{if $datainfo['OrderInvoice']['status'] == 2 }}
        <p class="alert alert-success">已开具。</p>
{{elseif $datainfo['OrderInvoice']['status'] == 3 }}
        <p class="alert alert-warning">已快递。 </p>
{{elseif $datainfo['OrderInvoice']['status'] == 0 || $datainfo['OrderInvoice']['status'] == 1 }}
        <div  class="alert alert-warning"><p>后台查看发票申请时，自动将发票状态置为已受理，用户将不可修改。</p>
        <p>注意，离用户提交时间1小时以内的不用点击查看。给用户修改时间。</p>
        </div>
{{elseif $datainfo['OrderInvoice']['status'] == -1 }}
        <p class="alert alert-danger">已拒绝。 </p>
{{/if}}

<div class="tab-content">
  <div role="tabpanel" class="tab-pane active" id="OrderInvoiceInfo">
    <div class="clearfix">
        <label class="col-sm-2">发票抬头：</label>
        <div class="col-sm-8 controls">
            <span style="color:red"> {{$datainfo['OrderInvoice']['name']}}</span>
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2">纳税人识别号：</label>
        <div class="col-sm-8 controls">
            <span style="color:red"> {{$datainfo['OrderInvoice']['ivc_nsrcode']}}</span>
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2">开票金额：</label>
        <div class="col-sm-8 controls">
           <span style="color:red"> {{$datainfo['OrderInvoice']['invoice_value']}}</span>
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2">发票类型：</label>
        <div class="col-sm-8 controls">
          		 专业技术服务
        </div>
    </div>
    <hr style="margin:10px 0;">
    <div class="clearfix">
        <label class="col-sm-2">收件人：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['receiver']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2">快递地址：</label>
        <div class="col-sm-8 controls">
          {{$datainfo['OrderInvoice']['province']}}&nbsp; {{$datainfo['OrderInvoice']['city']}}&nbsp; {{$datainfo['OrderInvoice']['area']}} &nbsp; {{$datainfo['OrderInvoice']['address']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" >手机号：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['mobile']}}
        </div>
    </div>
    
    <div class="clearfix">
        <label class="col-sm-2">邮政编码：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['postcode']}}
        </div>
    </div>
    
    <div class="clearfix">
        <label class="col-sm-2" for="OrderInvoiceEmail">备注：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['content']}}
        </div>
    </div>
    
    <div class="clearfix">
        <label class="col-sm-2" for="OrderInvoiceEmail">审核信息：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['audit_msg']}}
        </div>
    </div>
    <hr style="margin:10px 0;">
    <div class="clearfix">
        <label class="col-sm-2" for="OrderInvoiceEmail">注册地址：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['ivc_address']}}
        </div>
    </div>
    
    <div class="clearfix">
        <label class="col-sm-2" for="OrderInvoiceEmail">注册电话：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['ivc_phone']}}
        </div>
    </div>
    <div class="clearfix">
        <label class="col-sm-2" for="OrderInvoiceEmail">开户银行：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['ivc_bank']}}
        </div>
    </div>
    
    <div class="clearfix">
        <label class="col-sm-2" for="OrderInvoiceEmail">银行账号：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['ivc_bankcode']}}
        </div>
    </div>

    <hr style="margin:10px 0;"/>
	
	<div class="clearfix">
        <label class="col-sm-2" >发票号：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['invoice_number']}}
        </div>
    </div>
    
    <div class="clearfix">
        <label class="col-sm-2">快递单号：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['courier_number']}}
        </div>
    </div>
    
    <div class="clearfix">
        <label class="col-sm-2" >申请用户编号：</label>
        <div class="col-sm-8 controls">
            {{$datainfo['OrderInvoice']['creator']}}
        </div>
    </div>
    
    <hr/>
    <div class="ui-portlet-header">
			      <span class="title">发票操作</span>            
</div>
     <div>
    
    
        <div class="row" style="margin:0 auto;">
        	{{if $datainfo['OrderInvoice']['status'] == 0 || $datainfo['OrderInvoice']['status'] == 1  }}
            <div class="col-md-3 ">
	            {{$this->MForm->create('OrderInvoice',array('url'=>'/admin/order_invoices/edit/'.$datainfo['OrderInvoice']['id'],'class'=>'form-horizontal','id'=>"OrderInvoiceAddForm",'role'=>'form'))}}         
	            	<input type="hidden" name="data[OrderInvoice][id]" value="{{$datainfo['OrderInvoice']['id']}}">
	            	<input type="hidden" name="data[OrderInvoice][status]" value="2">
	            	
	<div class="form-group clearfix">
        <label class="col-sm-4">发票号:</label>
        <div class="col-sm-8 controls">
        	{{$this->MForm->input('invoice_number',array('div'=>false,'type'=>'number','label'=>false,'required'=>"required",'id'=>'OrderInvoiceInvoiceNumber1'))}}
        </div>
    </div>
    <div class="form-group clearfix">
        <label class="col-sm-4"></label>
        <div class="col-sm-8 controls">
            <button onclick="ajaxAction(this.form);window.location.reload();" class="btn btn-primary" >已开具</button>
        </div>
    </div>
	        	</form>
            </div>
            {{/if}}
            {{if $datainfo['OrderInvoice']['status'] >= 0  }}
            <div class="col-md-3 ">   
            	{{$this->MForm->create('OrderInvoice',array('url'=>'/admin/order_invoices/edit/'.$datainfo['OrderInvoice']['id'],'class'=>'form-horizontal','id'=>"OrderInvoiceAddForm",'role'=>'form'))}}         
	            	<input type="hidden" name="data[OrderInvoice][id]" value="{{$datainfo['OrderInvoice']['id']}}">
	            	<input type="hidden" name="data[OrderInvoice][status]" value="3">
	<div class="form-group clearfix">
        <label class="col-sm-4">发票号:</label>
        <div class="col-sm-8 controls">
        	{{$this->MForm->input('invoice_number',array('div'=>false,'type'=>'number','label'=>false,'required'=>"required",'id'=>'OrderInvoiceInvoiceNumber2'))}}
        </div>
    </div>
    <div class="form-group clearfix">
        <label class="col-sm-4">快递类型: </label>
        <div class="col-sm-8 controls">
        	{{$this->MForm->input('OrderInvoice.courier_type',array('div'=>false,'label'=>false,'required'=>"required",))}}
        	<input type="hidden" name="data[OrderInvoice][courier_time]" value="{{date('Y-m-d H:i:s')}}">
        </div>
    </div>
    <div class="form-group clearfix">
        <label class="col-sm-4">快递单号: </label>
        <div class="col-sm-8 controls">
        	{{$this->MForm->input('courier_number',array('div'=>false,'type'=>'number','label'=>false,'required'=>"required",))}}
        </div>
    </div>
    <div class="form-group clearfix">
        <label class="col-sm-4"></label>
        <div class="col-sm-8 controls">
            <button onclick="ajaxAction(this.form);window.location.reload();" class="btn btn-primary" >已快递</button>
        </div>
    </div>
	        	</form>
            </div>
            {{/if}}
            
            <div class="col-md-3">
		        {{$this->MForm->create('OrderInvoice',array('url'=>'/admin/order_invoices/edit/'.$datainfo['OrderInvoice']['id'],'class'=>'form-horizontal','id'=>"OrderInvoiceAddForm",'role'=>'form'))}}         
	            	   
		            <input type="hidden" name="data[OrderInvoice][id]" value="{{$datainfo['OrderInvoice']['id']}}">
	<div class="form-group clearfix">
		<p>修改备注</p>
				{{$this->MForm->input('content',array('div'=>false,'required'=>"required",'label'=>false,'default'=>'请输入备注内容'))}}
		    <button onclick="ajaxAction(this.form);window.location.reload();" style="margin-top: 10px;" class="btn btn-primary" >修改备注</button>
    </div>
		            
		        </form>
            </div>
            
            {{if $datainfo['OrderInvoice']['status'] == 0 || $datainfo['OrderInvoice']['status'] == 1 || $datainfo['OrderInvoice']['status'] == -1 }}
            
            <div class="col-md-3">
		        {{$this->MForm->create('OrderInvoice',array('url'=>'/admin/order_invoices/edit/'.$datainfo['OrderInvoice']['id'],'class'=>'form-horizontal','id'=>"OrderInvoiceAddForm",'role'=>'form'))}}         
	            	   
		            <input type="hidden" name="data[OrderInvoice][id]" value="{{$datainfo['OrderInvoice']['id']}}">
		            <input type="hidden" name="data[OrderInvoice][status]" value="-1">
	<div class="form-group clearfix">
		<p>地址完整或抬头的正确性? 客户取消？请详细注明，便于查看。</p>
				{{$this->MForm->input('audit_msg',array('div'=>false,'required'=>"required",'label'=>false,'default'=>'请注明原因'))}}
		    <button onclick="if(confirm('是否确认审核不通过')) { ajaxAction(this.form);window.location.reload();}" style="margin-top: 10px;" class="btn btn-warning" >审核不通过</button>
    </div>
		            
		        </form>
            </div>
            {{/if}}
            
            
        </div>    
    
       </div>
       
       
   <?PHP  $user_id = $datainfo['OrderInvoice']['creator']; $total_price = 0; ?>
   
   
   
   <p><br></p>
   <div class="ui-portlet-header">
			      <span class="title">用户历史支付订单记录</span>            
	</div>
   <table>
   	<thead><tr><th>订单编号</th><th>订单时间</th><th>订单金额</th><th>操作</th></tr></thead>
   	<portlet cache="no" list_tpl="inner" portlet="body"  model="Order" limit="100" fields="Order.*" order="id desc" info="conditions[creator]=$user_id&conditions[status]=1">
   		<tr><td>{{$item['id']}}</td><td>{{$item['created']}}</td><td>{{$item['total_price']}}</td><td><a href="/admin/orders/view/{{$item['id']}}" target="_blank">查看</a></td></tr>
   		<?PHP $total_price += $item['total_price']; ?>
   	</portlet>
   </table>
   <P style="text-align:right;">总金额：{{$total_price}}</P>
   
   <?PHP $total_price = 0; ?>
   <p><br></p>
   <div class="ui-portlet-header">
			      <span class="title">用户开票申请记录(含当次)</span>
			      <small style="font-size: 12px;">（状态：-1 已作废，0已提交，1已受理，2已开具，3已快递）</small>            
	</div>
   <table>
   	<thead><tr><th>开票编号</th><th>申请时间</th><th>开票金额</th><th>开票状态</th><th>发票抬头</th><th>收件人</th><th>操作</th></tr></thead>
   	<portlet cache="no" list_tpl="inner" portlet="body"  model="OrderInvoice" limit="100" fields="OrderInvoice.*" order="id desc" info="conditions[creator]=$user_id">
   		<tr><td>{{$item['id']}}</td><td>{{$item['created']}}</td><td>{{$item['invoice_value']}}</td><td>{{$item['status']}}</td><td>{{$item['name']}}</td><td>{{$item['receiver']}}</td><td><a href="/admin/order_invoices/view/{{$item['id']}}" target="_blank">查看</a></td></tr>
   		<?PHP $total_price += $item['invoice_value']; ?>
   	</portlet>
   </table>
   <P style="text-align:right;">总金额：{{$total_price}}</P>
   
   </div>
   
</div>